package com.webtair.dump4j.core;

import java.util.ArrayList;
import java.util.List;

public class Item {
	private long id;
	private ArrayList<Item> children = new ArrayList<Item>(); 
	private String name;
	private String value;
	private String className;
	private boolean isDuplicate;
	private static long ids=1;
	private int level;
	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	private static long generateId(){
		return ids++;
	}

	private Item(Item item){
		this.name = item.name;
		this.value = item.value;
		this.id = item.id; 
		this.className = item.className;
		isDuplicate = true;
	}
	public Item(String className,String name, String value) {
		super();
		this.className = className;
		this.name = name;
		this.value = value;
		this.id = generateId();
		
	}

	/**
	 * @return Returns the name.
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name The name to set.
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return Returns the value.
	 */
	public String getValue() {
		return value;
	}

	/**
	 * @param value The value to set.
	 */
	public void setValue(String value) {
		this.value = value;
	}

	/**
	 * @return Returns the children.
	 */
	public List<Item> getChildren() {
		return children;
	}

	public void addChild(Item child){
		children.add(child);
	}

	/**
	 * @return Returns the id.
	 */
	public long getId() {
		return id;
	}
	
	public static Item shallowClone(Item item){
		return new Item(item);
	}

	/**
	 * @return Returns the className.
	 */
	public String getClassName() {
		return className;
	}

	/**
	 * @param className The className to set.
	 */
	public void setClassName(String className) {
		this.className = className;
	}

	public boolean isDuplicate() {
		return isDuplicate;
	}

	//FIXME: workaround
	public static void clearIdPool() {
		ids = 1;
	}
	
}
